package com.xpgk.mvc.loseWeightCustomerRanking;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.jfinal.plugin.activerecord.Record;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.scallVisit.ScallVisitXLS;

import net.sf.ehcache.util.FindBugsSuppressWarnings;

public class LoseWeightCustomerRankingController extends BaseController{
	
	LoseWeightCustomerRankingService loseWeightCustomerRankingService;
	
	public  void  index(){
		Organization organ=Organization.dao.findById(getCUserOrganIds());
		setAttr("organization", organ);
		List<Record> productData = loseWeightCustomerRankingService.productData();
		setAttr("productData", productData);
		render("loseWeightCustomerRanking.html");
	}
	
	/*
	 * 顾客信息查询
	 */
	public void customerQuery(){
		String date = getPara("maxTime");
		String organIdsEmployee = getPara("organIdsEmployee");
		String hybh = getPara("hybh");
		String customerName = getPara("customerName");
		String customerPhone = getPara("customerPhone");
		
		List<Record> result = loseWeightCustomerRankingService.customerDataQuery(organIdsEmployee, date,hybh,customerName,customerPhone);
		renderJson(result);
	}
	/*
	 * 顾客信息Excel导出
	 */
	public void excel(){
		
		String date = getPara("maxTime");
		String organIdsEmployee = getPara("organIds");
		String hybh = getPara("hybh");
		String customerName = getPara("customerName");
		String customerPhone = getPara("customerPhone");
		Organization organ = Organization.dao.findById(organIdsEmployee);//门店
		String search_organIdsEmployee =organ.getStr(Organization.column_name).equals("")?"":("店面名称："+organ.getStr(Organization.column_name)+"，");
		List<Record> result = loseWeightCustomerRankingService.customerDataQuery(organIdsEmployee, date,hybh,customerName,customerPhone);
		List<Record> productData = loseWeightCustomerRankingService.productData();
		for(Record r : productData){
			System.out.println(r);
		}
		
		String search=search_organIdsEmployee+"日期："+date;
		render(new LoseWeightCustomerRankingXLS(productData,result, "当日顾客到店减重排名表",search));
	}
}
